﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Gollie.Ajax
{
	public class VendorSettings : AjaxResult
	{
		public UserInfo Ui;

		public VendorSettings() : base(null) { }

		public VendorSettings(AjaxArg arg)
			: base(arg)
		{
		}

		protected override void Init(AjaxArg ajaxArg)
		{
			try
			{
				object o = HttpContext.Current.Session["userinfo"];

				if (o == null)
				{
					throw new Exception("Niet ingelogd");
				}

				Ui = o as UserInfo;
				if (Ui.Role != Role.Administrator)
					throw new Exception("Illegal method call GetVendorSettings");
			}
			catch (Exception e)
			{
				if (this.ErrorCode == 0)
					this.ErrorCode = 99;

				this.ErrorMessage = e.Message;
				logger.Info("GetVendorSettings failed: {0}", this.ErrorMessage);
			}
		}
	}
}